package com.erpanderp.wam.usm.model.service.leave;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.hibernate.FlushMode;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;

import com.erpanderp.wam.ac.model.entity.travel.TravelRequest;
import com.erpanderp.wam.usm.model.entity.leave.EmployeeLeave;
import com.erpanderp.wam.usm.model.entity.leave.LeaveBalance;
import com.erpanderp.wam.usm.model.entity.timesheet.TimesheetDetail;
import com.erpanderp.wam.util.CommonLookup;
import com.erpanderp.wam.util.HibernateUtil;

public class EmployeeLeaveDAO {
	
	public EmployeeLeave employeeLeaveApply(EmployeeLeave employeeLeave){
		System.out.println("LEAVE TO BE APPLIED");
		try{
			Session session = HibernateUtil.getSessionFactory().getCurrentSession();
			session.setFlushMode(FlushMode.AUTO);
			session.beginTransaction();
			session.save(employeeLeave);
			session.getTransaction().commit();
		}catch (Exception e) {
			e.printStackTrace();
			return null;
		}
		return employeeLeave;
	}
	
	
	

	
    public String getLastGeneratedLeaveCODE(){
		
		String queryString="select el.leaveCode from EmployeeLeave el";
		
		System.out.println("QUERY: " + queryString);
		
		List<String> codeList = null;
		
		try{
			Session session = HibernateUtil.getSessionFactory().getCurrentSession();
			session.getTransaction().begin();		
			Query query = session.createQuery(queryString);
			query.setCacheable(false);
			codeList = (List<String>) query.list();
			session.getTransaction().commit();
		}catch(HibernateException e){
			e.printStackTrace();
		}
		
		String lastCode = null;
		for (String code : codeList) {
			if(code != null && code.toUpperCase().startsWith("E5")){
				System.out.println("Code: " + code);
				continue;//Only for ERP and ERP to skip migrated code.
			} 
			if (lastCode == null) {
				lastCode = code;
				continue;
				
			}else if (Long.parseLong(code.substring(code.indexOf("-")+1)) > Long.parseLong(lastCode.substring(lastCode.indexOf("-")+1))) {
					lastCode = code;
					continue;
				
			}
			System.out.println(lastCode + "============ " + code);
		}		
		return lastCode;	
	}
   
    public EmployeeLeave getEmployeeLeaveByLeaveCODE(String leaveCode){
    	System.out.println("EMPLOYEELEAVE CALLED BY LEAVECODE");
    	EmployeeLeave employeeLeave = new EmployeeLeave();
    	try{
    		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    		session.beginTransaction();
    		session.setFlushMode(FlushMode.AUTO);
    		String queryString = "from EmployeeLeave el where el.leaveCode = :leaveCode";
    		Query query = session.createQuery(queryString).setString("leaveCode", leaveCode);
    		query.setCacheable(false);
    		employeeLeave = (EmployeeLeave) query.uniqueResult();
    		session.getTransaction().commit();
    		return employeeLeave;
    	}catch (Exception e) {
    		e.printStackTrace();
    		return null;
		}    	
    }
    
    public boolean leaveApprovedByApprovalComments(EmployeeLeave employeeLeave){
    	boolean leaveApproved = true;
    	try{
    		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    		session.setFlushMode(FlushMode.AUTO);
    		session.beginTransaction();
    		session.update(employeeLeave);
    		session.getTransaction().commit();
    		return leaveApproved;
        	
    	}catch (Exception e) {
    		e.printStackTrace();
    		return false;
		}
		
    }
    public boolean leaveRejectedByApprovalComments(EmployeeLeave employeeLeave){
    	boolean leaveRejected = true;
    	try{
    		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    		session.setFlushMode(FlushMode.AUTO);
    		session.beginTransaction();
    		session.update(employeeLeave);
    		session.getTransaction().commit();
    		return leaveRejected;
        	
    	}catch (Exception e) {
    		e.printStackTrace();
    		return false;
		}
    	
    }
    public List<EmployeeLeave> getAllAppliedLeavesByEmployeeID(Long employeeId){
    	List<EmployeeLeave> employeeLeaves = null;
    	try{
    		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    		session.beginTransaction();
    		session.setFlushMode(FlushMode.AUTO);
    		String queryString = "from EmployeeLeave el where el.employee.employeeId = :employeeId order by el.createDate desc";
    		Query query = session.createQuery(queryString).setLong("employeeId", employeeId);
    		employeeLeaves = (List<EmployeeLeave>)query.list();
    		return employeeLeaves;
    		
    	}catch (Exception e) {
    		e.printStackTrace();
    		return null;
		}
    	
    }
    
    public List<EmployeeLeave> getAllCancellationLeavesByEmployeeID(Long employeeId){
    	String cancellationInprocessStatus = CommonLookup.LEAVE_CANCELLATION_INPROCESS_STATUS;
    	String cancellationAcceptedStatus = CommonLookup.LEAVE_CANCELLATION_ACCEPTED_STATUS;
    	String cancellationRejectedStatus = CommonLookup.LEAVE_CANCELLATION_REJECTED_STATUS;
    	String cancellationMyselfStatus = CommonLookup.LEAVE_CANCELLATION__MYSELF_STATUS;

    	List<EmployeeLeave> employeeLeaves = null;
    	try{
    		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    		session.beginTransaction();
    		session.setFlushMode(FlushMode.AUTO);
    		String queryString = "from EmployeeLeave el where el.cancellationStatus in(:cancellationInprocessStatus,:cancellationAcceptedStatus,:cancellationRejectedStatus,:cancellationMyselfStatus)  and el.employee.employeeId = :employeeId";
    		Query query = session.createQuery(queryString).setLong("employeeId", employeeId).setString("cancellationInprocessStatus", cancellationInprocessStatus).setString("cancellationAcceptedStatus", cancellationAcceptedStatus).setString("cancellationRejectedStatus", cancellationRejectedStatus)
    				.setString("cancellationMyselfStatus", cancellationMyselfStatus);
    		employeeLeaves = (List<EmployeeLeave>)query.list();
    		System.out.println("CANCELLATION LEAVES LIST SIZE ="+employeeLeaves.size());
    		return employeeLeaves;
    		
    	}catch (Exception e) {
    		e.printStackTrace();
    		return null;
		}
    	
    }
    
    
    public EmployeeLeave leaveCancelRequestByEmployee(EmployeeLeave employeeLeave){
		try{
			Session session = HibernateUtil.getSessionFactory().getCurrentSession();
			session.setFlushMode(FlushMode.AUTO);
			session.beginTransaction();
			session.update(employeeLeave);
			session.getTransaction().commit();
			return employeeLeave;
		}catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
    
    public List<Date> getEmployeeLeaveDates(Date periodFrom, Date periodTo, Long employeeId){
    	List<Date> leaveDates = new ArrayList<Date>();
    	System.out.println(periodFrom + " " + periodTo);
    	try{
			Session session = HibernateUtil.getSessionFactory().getCurrentSession();
			session.setFlushMode(FlushMode.COMMIT);
			session.beginTransaction();
			String queryString = "from EmployeeLeave el where el.employee.employeeId = :employeeId and ((el.periodFrom >= :periodFrom and el.periodTo <= :periodTo))";
			Query query = session.createQuery(queryString).setDate("periodFrom", periodFrom).setDate("periodTo", periodTo).setLong("employeeId", employeeId);
			List<EmployeeLeave> temp= (List<EmployeeLeave>) query.list();
			
			if(temp != null && temp.size() > 0){
				for(EmployeeLeave employeeLeave : temp){
					System.out.println(employeeLeave.getEmploymentLeaveid());
					leaveDates.add(employeeLeave.getPeriodFrom());
					
					if(employeeLeave.getNoOfDays() > 1){
						Calendar calendar = Calendar.getInstance();
						calendar.setTime(employeeLeave.getPeriodFrom());
						for(int i = 2; i <= employeeLeave.getNoOfDays(); i++){
							calendar.add(Calendar.DAY_OF_MONTH, 1);
							leaveDates.add(calendar.getTime());
						}	
						
					}
					
				}	
			}
			
			session.getTransaction().commit();
			return leaveDates;
		}catch (Exception e) {
			e.printStackTrace();
			return null;
		}
    }
  
    
    public Map<Date, String> getApprovedEmployeeLeaveDates(Date periodFrom, Date periodTo, Long employeeId){
    	Map<Date, String> resultMap = new HashMap<Date, String>();
    	System.out.println(periodFrom + " " + periodTo);
    	try{
			Session session = HibernateUtil.getSessionFactory().getCurrentSession();
			session.setFlushMode(FlushMode.COMMIT);
			session.beginTransaction();
			String queryString = "from EmployeeLeave el where el.employee.employeeId = :employeeId and (el.periodFrom >= :periodFrom and el.periodTo <= :periodTo) and el.approvalStatus = :approvalStatus";
			Query query = session.createQuery(queryString).setDate("periodFrom", periodFrom).setDate("periodTo", periodTo).setLong("employeeId", employeeId).setString("approvalStatus", CommonLookup.LEAVE_APPROVED_STATUS);
			List<EmployeeLeave> temp= (List<EmployeeLeave>) query.list();
			
			if(temp != null && temp.size() > 0){
				for(EmployeeLeave employeeLeave : temp){
					System.out.println(employeeLeave.getEmploymentLeaveid());
					resultMap.put(employeeLeave.getPeriodFrom(), employeeLeave.getLeaveType().getLeaveType());
					if(employeeLeave.getNoOfDays() > 1){
						Calendar calendar = Calendar.getInstance();
						calendar.setTime(employeeLeave.getPeriodFrom());
						for(int i = 2; i <= employeeLeave.getNoOfDays(); i++){
							calendar.add(Calendar.DAY_OF_MONTH, 1);
							resultMap.put(calendar.getTime(), employeeLeave.getLeaveType().getLeaveType());
						}	
					}
					
				}	
			}
			
			session.getTransaction().commit();
			return resultMap;
		}catch (Exception e) {
			e.printStackTrace();
			return null;
		}
    }
    
    public List<Date> getApprovedEmployeeLeaveDatesBy(Date periodFrom, Date periodTo, Long employeeId){
    	System.out.println("@APPROVED");
    	String approvalStatus = CommonLookup.LEAVE_APPROVED_STATUS;
    	
    	List<Date> leaveDates = new ArrayList<Date>();
    	System.out.println(periodFrom + " " + periodTo);
    	try{
			Session session = HibernateUtil.getSessionFactory().getCurrentSession();
			session.setFlushMode(FlushMode.COMMIT);
			session.beginTransaction();
			String queryString = "from EmployeeLeave el where el.employee.employeeId = :employeeId and (el.periodFrom >= :periodFrom and el.periodTo <= :periodTo) and (el.approvalStatus=:approvalStatus)";
			Query query = session.createQuery(queryString).setDate("periodFrom", periodFrom).setDate("periodTo", periodTo).setLong("employeeId", employeeId).setString("approvalStatus",approvalStatus);
			List<EmployeeLeave> temp= (List<EmployeeLeave>) query.list();
			
			if(temp != null && temp.size() > 0){
				for(EmployeeLeave employeeLeave : temp){
					System.out.println(employeeLeave.getEmploymentLeaveid());
					leaveDates.add(employeeLeave.getPeriodFrom());
					
					if(employeeLeave.getNoOfDays() > 1){
						Calendar calendar = Calendar.getInstance();
						calendar.setTime(employeeLeave.getPeriodFrom());
						for(int i = 2; i <= employeeLeave.getNoOfDays(); i++){
							calendar.add(Calendar.DAY_OF_MONTH, 1);
							leaveDates.add(calendar.getTime());
						}	
						
					}
					
				}	
			}
			
			session.getTransaction().commit();
			return leaveDates;
		}catch (Exception e) {
			e.printStackTrace();
			return null;
			// TODO: handle exception
		}
    }
    
    public List<Date> getInprocessEmployeeLeaveDatesBy(Date periodFrom, Date periodTo, Long employeeId){
    	System.out.println("@INPROCESS");
    	
    	String approvalStatus = CommonLookup.LEAVE_INPROCESS_STATUS;
    	List<Date> leaveDates = new ArrayList<Date>();
    	System.out.println(periodFrom + " " + periodTo);
    	try{
			Session session = HibernateUtil.getSessionFactory().getCurrentSession();
			session.setFlushMode(FlushMode.COMMIT);
			session.beginTransaction();
			String queryString = "from EmployeeLeave el where el.employee.employeeId = :employeeId and (el.periodFrom >= :periodFrom and el.periodTo <= :periodTo) and (el.approvalStatus=:approvalStatus)";
			Query query = session.createQuery(queryString).setDate("periodFrom", periodFrom).setDate("periodTo", periodTo).setLong("employeeId", employeeId).setString("approvalStatus",approvalStatus);
			List<EmployeeLeave> temp= (List<EmployeeLeave>) query.list();
			
			if(temp != null && temp.size() > 0){
				for(EmployeeLeave employeeLeave : temp){
					System.out.println(employeeLeave.getEmploymentLeaveid());
					leaveDates.add(employeeLeave.getPeriodFrom());
					
					if(employeeLeave.getNoOfDays() > 1){
						Calendar calendar = Calendar.getInstance();
						calendar.setTime(employeeLeave.getPeriodFrom());
						for(int i = 2; i <= employeeLeave.getNoOfDays(); i++){
							calendar.add(Calendar.DAY_OF_MONTH, 1);
							leaveDates.add(calendar.getTime());
						}	
						
					}
					
				}	
			}
			
			session.getTransaction().commit();
			return leaveDates;
		}catch (Exception e) {
			e.printStackTrace();
			return null;
			// TODO: handle exception
		}
    }
    
    public EmployeeLeave getEmployeeLeaveByLeaveCancellationStatus(String cancellationStatus,Long employeeId){
    	EmployeeLeave employeeLeave = null;
		try{
			Session session = HibernateUtil.getSessionFactory().getCurrentSession();
			session.setFlushMode(FlushMode.AUTO);
			session.beginTransaction();
			String queryString = "from EmployeeLeave el where el.cancellationStatus = :cancellationStatus and el.employee.employeeId = :employeeId";
			Query query = session.createQuery(queryString).setString("cancellationStatus", cancellationStatus).setLong("employeeId", employeeId);
			employeeLeave = (EmployeeLeave) query.uniqueResult();
			session.getTransaction().commit();
			return employeeLeave;
		}catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
    
    public List<EmployeeLeave> getEmployeeLeavesByInProcessEmployeeIdAndLeaveTypeId(Long employeeId,String approvalStatus,Long leaveTypeid){
    	System.out.println("IN DAO = "+"LEAVE TYPE ID = "+leaveTypeid+" LOGIN USER ID ="+employeeId);
    	List<EmployeeLeave> employeeLeaves = null;
		try{
			Session session = HibernateUtil.getSessionFactory().getCurrentSession();
			session.setFlushMode(FlushMode.AUTO);
			session.beginTransaction();
			String queryString = "from EmployeeLeave el where el.approvalStatus =:approvalStatus and (el.employee.employeeId =:employeeId and el.leaveType.leaveTypeid =:leaveTypeid)";
			Query query = session.createQuery(queryString).setString("approvalStatus", approvalStatus).setLong("employeeId", employeeId).setLong("leaveTypeid", leaveTypeid);
			employeeLeaves = query.list();
			System.out.println("EMPLOYEE LEAVES ="+employeeLeaves.size());
			
			return employeeLeaves;
		}catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
    
    
    //GET EMPLYEE LEAVES BASED ON COMPETENCY
    public List<EmployeeLeave> getAllLeavesByCompetency(String employeeCode,Date selectDate){
    	List<EmployeeLeave> employeeLeaves = null;
    	try{
    		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    		session.beginTransaction();
    		session.setFlushMode(FlushMode.AUTO);
    		System.out.println("==========EMPLEAVE DAO==========");
    		//Query query = session.createQuery("from EmployeeAndReporting er where er.competencelead.employeeCode =:employeeCode)");
    		//from EmployeeSkillMatrix es where es.employee.employeeCode in (select er.employee.employeeCode from EmployeeAndReporting er where er.competencelead.employeeCode =:employeeCode)
    		String queryString = "from EmployeeLeave el where el.employee.employeeCode in (select er.employee.employeeCode from EmployeeAndReporting er where er.competencelead.employeeCode =:employeeCode) and ((el.periodFrom >= :selectDate and el.periodTo <= :selectDate))";
    		//String queryString = "from EmployeeLeave el where el.employee.employeeCode in (select er.employee.employeeCode from EmployeeAndReporting er where er.competencelead.employeeCode =:employeeCode) and (:selectDate between el.periodFrom and el.periodTo))";
    		Query query = session.createQuery(queryString).setString("employeeCode", employeeCode).setDate("selectDate", selectDate);
    		employeeLeaves = (List<EmployeeLeave>)query.list();
    		return employeeLeaves;
    		
    	}catch (Exception e) {
    		e.printStackTrace();
    		return null;			
		}    	
    }
    
    public List<EmployeeLeave> getInprocessLeavesListUnderWAMUserCompetency(String approvalStatus,String cancellationStatus,Long employeeId){
    	List<EmployeeLeave> employeeLeavesList = new ArrayList<EmployeeLeave>();
    	
    	try{
    		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    		session.beginTransaction();
    		session.setFlushMode(FlushMode.AUTO);
    		System.out.println("==========EMP LEAVE DAO==========");
    		
    		String queryString = "from EmployeeLeave el where el.approver.employeeId=:employeeId and el.approvalStatus=:approvalStatus";
    		
    		Query query = session.createQuery(queryString).setLong("employeeId", employeeId).setString("approvalStatus", approvalStatus);
    		employeeLeavesList = (List<EmployeeLeave>)query.list();
    		return employeeLeavesList;
    		
    	}catch (Exception e) {
    		e.printStackTrace();
    		return null;			
		}    	
    }
    
    public List<EmployeeLeave> getCancellationInprocessLeavesListUnderWAMUserCompetency(String approvalStatus,Long employeeId){
    	List<EmployeeLeave> employeeLeavesList = new ArrayList<EmployeeLeave>();
    	try{
    		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    		session.beginTransaction();
    		session.setFlushMode(FlushMode.AUTO);
    		System.out.println("==========EMP LEAVE DAO==========");
    		
    		String queryString = "from EmployeeLeave el where el.approver.employeeId=:employeeId and el.approvalStatus=:approvalStatus";
    		
    		Query query = session.createQuery(queryString).setLong("employeeId", employeeId).setString("approvalStatus", approvalStatus);
    		employeeLeavesList = (List<EmployeeLeave>)query.list();
    		return employeeLeavesList;
    		
    	}catch (Exception e) {
    		e.printStackTrace();
    		return null;			
		}    	
    }
    
    /**
     * Get all requested leaves
     * @param approverId
     * @param status
     * @return
     */
    public List<EmployeeLeave> getLeaves(Long approverId, String status){
    	List<EmployeeLeave> employeeLeaves = null;
		try {
			Session session = HibernateUtil.getSessionFactory().getCurrentSession();
			session.beginTransaction();
			session.setFlushMode(FlushMode.COMMIT);
			
			String queryString = "from EmployeeLeave el where el.approver.employeeId = :approverId";
			if(status != null && !status.equals(""))
				queryString += " and el.approvalStatus = :status";
			
			queryString += " order by el.appliedOn desc";
			Query query = session.createQuery(queryString);
			query.setCacheable(false).setLong("approverId",	approverId);
			if(status != null && !status.equals(""))
				query.setString("status", status);
			
			employeeLeaves = (List<EmployeeLeave>) query.list();
			session.getTransaction().commit();
			return employeeLeaves;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}    	
    }
    
    
    public List<EmployeeLeave> getUnacknowledgedLeaves(Long employeeId){
    	List<EmployeeLeave> employeeLeaves = null;
		try {
			Session session = HibernateUtil.getSessionFactory().getCurrentSession();
			session.beginTransaction();
			session.setFlushMode(FlushMode.COMMIT);
			
			String queryString = "from EmployeeLeave el where el.employee.employeeId = :employeeId and el.approvalStatus != 'IN PROCESS' and (el.managerActionAcknowledged = 'NOT_ACKNOWLEDGED' or el.managerActionAcknowledged is null) order by el.appliedOn desc";
				
			Query query = session.createQuery(queryString);
			query.setCacheable(false).setLong("employeeId",	employeeId);
			
			employeeLeaves = (List<EmployeeLeave>) query.list();
			session.getTransaction().commit();
			return employeeLeaves;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}    	
    }
    
    public List<EmployeeLeave> getEmplolyeeLeavesByStatus(Date fromDate, Date toDate, String approvalStatus){
    	System.out.println("IN DAO");
		List<EmployeeLeave> employeeLeaves = null;
		
		try {
			Session session = HibernateUtil.getSessionFactory().getCurrentSession();
			session.getTransaction().begin();
			session.setFlushMode(FlushMode.COMMIT);
			String queryString = "from EmployeeLeave el where el.approvalStatus = :approvalStatus" +
								" and (el.periodFrom >= :fromDate and el.periodFrom <= :toDate and el.periodTo >= :fromDate and el.periodTo <= :toDate) order by el.employee.employeeCode asc";
			Query query = session.createQuery(queryString);
			query.setString("approvalStatus", approvalStatus).setDate("fromDate", fromDate).setDate("toDate", toDate);
			employeeLeaves = (List<EmployeeLeave>) query.list();
			session.getTransaction().commit();
			return employeeLeaves;
			
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
    
    
    public List<EmployeeLeave> getEmplolyeeLeavesByStatus(Date fromDate, Date toDate, String approvalStatus, Long employeeId){
    	
    	System.out.println("IN DAO");
    	System.out.println("EMPLOYEE ID ="+employeeId);
		List<EmployeeLeave> employeeLeaves = null;
		
		try {
			Session session = HibernateUtil.getSessionFactory().getCurrentSession();
			session.getTransaction().begin();
			session.setFlushMode(FlushMode.COMMIT);
			String queryString = "from EmployeeLeave el where el.approvalStatus = :approvalStatus and el.approver.employeeId =:employeeId" +
								" and (el.periodFrom >= :fromDate and el.periodFrom <= :toDate and el.periodTo >= :fromDate and el.periodTo <= :toDate) order by el.employee.employeeCode asc";
			System.out.println("QUERY "+queryString);
			Query query = session.createQuery(queryString);
			query.setString("approvalStatus", approvalStatus).setDate("fromDate", fromDate).setDate("toDate", toDate).setLong("employeeId", employeeId);
			employeeLeaves = (List<EmployeeLeave>) query.list();
			session.getTransaction().commit();
			return employeeLeaves;
			
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
    
    public static void main(String a[]){
/*		System.out.println(new EmployeeLeaveDAO().getLastGeneratedLeaveCODE());
		System.out.println("PLE50003-3".substring("PLE50003-3".indexOf("-")+1));
        EmployeeLeave employeeLeave = new EmployeeLeave();

		//List temp = new EmployeeLeaveDAO().getEmployeeLeaveDates(new GregorianCalendar(2012, 3, 1).getTime(), new GregorianCalendar(2012, 3, 1).getTime(), 3l);
		List temp = new EmployeeLeaveDAO().getApprovedEmployeeLeaveDatesByCancelledStatus(new GregorianCalendar(2012, 6, 1).getTime(), new GregorianCalendar(2012, 6, 1).getTime(), 3l);
		System.out.println("EMPLOYEE LEAVE"+(employeeLeave == null));
		for(Date date : (List<Date>) temp){
		 System.out.println(date);
		}


		System.out.println(new EmployeeLeaveDAO().getAllLeavesByCompetency("E50002", new GregorianCalendar(2012, 5, 28).getTime()));
	//	System.out.println(temp);
*/
    	
    	System.out.println(new EmployeeLeaveDAO().getUnacknowledgedLeaves(45l));
	}   
}
